From 6cf88c430953ebd422566ad888258bc0b91039a7 Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Tue, 20 Feb 2007 12:18:29 +0000 Subject: [PATCH] linux/x86: Advertise which page table entries contain MFNs and hence need to be (un)canonicalized during save/restore. Signed-off-by: Jan Beulich --- .../arch/i386/kernel/Makefile | 1 + .../arch/i386/kernel/head-xen.S | 4 ++++ .../arch/x86_64/kernel/Makefile | 1 + .../arch/x86_64/kernel/head-xen.S | 5 ++++- .../x86-elfnote-as-preprocessor-macro.patch | 21 +++++++++++++++---- xen/include/public/elfnote.h | 6 ++++++ 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/linux-2.6-xen-sparse/arch/i386/kernel/Makefile b/linux-2.6-xen-sparse/arch/i386/kernel/Makefile index 843f3d2ceb..03d31c5098 100644 --- a/linux-2.6-xen-sparse/arch/i386/kernel/Makefile +++ b/linux-2.6-xen-sparse/arch/i386/kernel/Makefile @@ -98,4 +98,5 @@ n-obj-xen := i8259.o timers/ reboot.o smpboot.o trampoline.o obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) obj-y := $(call cherrypickxen, $(obj-y)) extra-y := $(call cherrypickxen, $(extra-y)) +%/head-xen.o %/head-xen.s: EXTRA_AFLAGS := endif diff --git a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S index 1582ded1aa..d788f323ae 100644 --- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S +++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S @@ -12,6 +12,8 @@ #include #include +#define _PAGE_PRESENT 0x1 + /* * References to members of the new_cpu_data structure. */ @@ -198,7 +200,9 @@ ENTRY(cpu_gdt_table) ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel") #ifdef CONFIG_X86_PAE ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes") + ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT) #else ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no") + ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long, _PAGE_PRESENT,_PAGE_PRESENT) #endif ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic") diff --git a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile index f5b837d353..ae36f842a4 100644 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile @@ -72,4 +72,5 @@ include $(srctree)/scripts/Makefile.xen obj-y := $(call filterxen, $(obj-y), $(n-obj-xen)) obj-y := $(call cherrypickxen, $(obj-y)) extra-y := $(call cherrypickxen, $(extra-y)) +%/head-xen.o %/head-xen.s: EXTRA_AFLAGS := endif diff --git a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S index 64add58353..b7ef0cbcb0 100644 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S @@ -25,6 +25,8 @@ #include +#define _PAGE_PRESENT 0x1 + .section .bootstrap.text, "ax", @progbits .code64 #define VIRT_ENTRY_OFFSET 0x0 @@ -49,7 +51,7 @@ ENTRY(_stext) #define NEXT_PAGE(name) \ $page = $page + 1; \ .org $page * 0x1000; \ - phys_/**/name = $page * 0x1000 + __PHYSICAL_START; \ + phys_##name = $page * 0x1000 + __PHYSICAL_START; \ ENTRY(name) NEXT_PAGE(init_level4_pgt) @@ -181,5 +183,6 @@ ENTRY(empty_zero_page) #endif /* !CONFIG_XEN_COMPAT_030002 */ ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .quad, startup_64) ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad, hypercall_page) + ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .quad, _PAGE_PRESENT,_PAGE_PRESENT) ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel") ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic") diff --git a/patches/linux-2.6.18/x86-elfnote-as-preprocessor-macro.patch b/patches/linux-2.6.18/x86-elfnote-as-preprocessor-macro.patch index 79054fc191..9989d78297 100644 --- a/patches/linux-2.6.18/x86-elfnote-as-preprocessor-macro.patch +++ b/patches/linux-2.6.18/x86-elfnote-as-preprocessor-macro.patch @@ -1,7 +1,7 @@ diff -pruN ../orig-linux-2.6.18/include/linux/elfnote.h ./include/linux/elfnote.h --- ../orig-linux-2.6.18/include/linux/elfnote.h 2007-01-12 18:19:44.000000000 +0000 +++ ./include/linux/elfnote.h 2007-01-12 18:21:02.000000000 +0000 -@@ -31,22 +31,24 @@ +@@ -31,22 +31,38 @@ /* * Generate a structure with the same shape as Elf{32,64}_Nhdr (which * turn out to be the same size and shape), followed by the name and @@ -25,9 +25,21 @@ diff -pruN ../orig-linux-2.6.18/include/linux/elfnote.h ./include/linux/elfnote. -2:.align 4 -3:\desc -4:.align 4 --.popsection ++#ifdef __STDC__ ++#define ELFNOTE(name, type, desctype, descdata...) \ ++.pushsection .note.name ; \ ++ .align 4 ; \ ++ .long 2f - 1f /* namesz */ ; \ ++ .long 4f - 3f /* descsz */ ; \ ++ .long type ; \ ++1:.asciz #name ; \ ++2:.align 4 ; \ ++3:desctype descdata ; \ ++4:.align 4 ; \ + .popsection -.endm -+#define ELFNOTE(name, type, desctype, descdata) \ ++#else /* !__STDC__, i.e. -traditional */ ++#define ELFNOTE(name, type, desctype, descdata) \ +.pushsection .note.name ; \ + .align 4 ; \ + .long 2f - 1f /* namesz */ ; \ @@ -37,7 +49,8 @@ diff -pruN ../orig-linux-2.6.18/include/linux/elfnote.h ./include/linux/elfnote. +2:.align 4 ; \ +3:desctype descdata ; \ +4:.align 4 ; \ -+.popsection ; ++.popsection ++#endif /* __STDC__ */ #else /* !__ASSEMBLER__ */ #include /* diff --git a/xen/include/public/elfnote.h b/xen/include/public/elfnote.h index 76bbf4fab8..e7738ab7f7 100644 --- a/xen/include/public/elfnote.h +++ b/xen/include/public/elfnote.h @@ -150,6 +150,12 @@ */ #define XEN_ELFNOTE_HV_START_LOW 12 +/* + * List of maddr_t-sized mask/value pairs describing how to recognize + * (non-present) L1 page table entries carrying valid MFNs (numeric). + */ +#define XEN_ELFNOTE_L1_MFN_VALID 13 + /* * System information exported through crash notes. * -- 2.30.2